"""
file: custom_exception.py
Author: 城下秋草
Desc: 自定义异常处理
"""
from pom.util.logger import logger

class CustomException(Exception):
    def __init__(self,message:str, err_code: int = 1000):
        self.message = message
        self.err_code = err_code
        super().__init__(message)

    def __str__(self):
        logger.error(f"发生了错误：{self.err_code}: {self.message}")
        return f"发生了错误：{self.err_code}: {self.message}"

class FileTypeError(CustomException):
    def __init__(self,filetype):
        message = f"{filetype}不匹配！"
        super().__init__(message,err_code=1001)

class ValidationError(CustomException):
    def __init__(self,message):
        super().__init__(message,err_code=1002)

class ElementNotFound(CustomException):
    def __init__(self,ele_id):
        message = f"{ele_id}元素未发现！"
        super().__init__(message,err_code=1003)